package com.briup.pts.service.impl;

import com.briup.pts.domain.bean.Log;
import com.briup.pts.mapper.LogMapper;
import com.briup.pts.service.LogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wy
 * @description
 * @data 2024/11/29  10:38
 */
@Service
@RequiredArgsConstructor
public class LogServiceImpl implements LogService {
private final LogMapper mapper;
    @Override
    public PageInfo<Log> pageQueryByCondition(Integer pageNum, Integer pageSize,
                                              String originalIp) {
        // 使用过PageHelper开启分页
        try (Page<Log> ignored = PageHelper.startPage(pageNum, pageSize)) {
            // 根据条件查询数据库中的数据
            List<Log> logs = mapper.queryByCondition(originalIp);

            // 将查询的结果数据放入到PageInfo中返回
            return new PageInfo<>(logs);
        }
    }
}
